Skip to content

Conversation

HeikoKlare
Copy link
Contributor

When calling GC#drawImage(), an operation is created (like for every execution on GC) which stores the image to draw. Since the image may be disposed afterwards, a dispose listener is registered to the image, such that the image can be copied and maintained inside the operation in case of a disposal until that operation itself is disposed. The listener is currently not de-registered when disposing the GC and its operations, thus the GC operations (and thus also the containing GC) will still be referenced (as listeners from the image) until that image is disposed. Since images may be long living (or never be disposed at all), this can lead to a memory leak.

This change removes the listener from the image upon disposal of a GC and its operations such that no memory can occur.

Fixes #2499

Copy link
Contributor

github-actions bot commented Sep 11, 2025

Test Results

  118 files  ±0    118 suites  ±0   10m 27s ⏱️ - 1m 32s
4 432 tests +1  4 411 ✅ +2  17 💤 ±0  4 ❌  - 1 
  298 runs  ±0    290 ✅ +1   4 💤 ±0  4 ❌  - 1 

For more details on these failures, see this check.

Results for commit 0b489c7. ± Comparison against base commit 8c237c5.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare marked this pull request as ready for review September 11, 2025 15:53
@HeikoKlare HeikoKlare linked an issue Sep 11, 2025 that may be closed by this pull request
@fedejeanne
Copy link
Contributor

The test failure seems unrelated (it's in the Browser tests). Rebasing.

When calling GC#drawImage(), an operation is created (like for every
execution on GC) which stores the image to draw. Since the image may be
disposed afterwards, a dispose listener is registered to the image, such
that the image can be copied and maintained inside the operation in case
of a disposal until that operation itself is disposed.
The listener is currently not de-registered when disposing the GC and
its operations, thus the GC operations (and thus also the containing GC)
will still be referenced (as listeners from the image) until that image
is disposed. Since images may be long living (or never be disposed at
all), this can lead to a memory leak.

This change removes the listener from the image upon disposal of a GC
and its operations such that no memory can occur.

Fixes eclipse-platform#2499
Copy link
Contributor

@akoch-yatta akoch-yatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well

@fedejeanne fedejeanne merged commit 07c2347 into eclipse-platform:master Sep 19, 2025
19 of 22 checks passed
@fedejeanne fedejeanne deleted the issue-2499 branch September 19, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GC#drawImage can produce memory leak [Win32] GC#drawImage can produce memory leak
3 participants